
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class t15 {
    public static void main(String[] args) {
        long srt = System.currentTimeMillis();
        int arr[] = {13, -14, -10, -4, 4, 4, 0, -14, 5, -9, -3, -10, 14, 7, -3, -4, -3, 12, -14, 2, -11, -6, 0, -7, 13, -2, -7, -11, -14, -13, 5, 14, -12, 11, -13, -1, -8, 2, 0, 4, 1, 4, 10, -8, -11, -8, 3, 1, 11, 4, -12, 8, 5, -4, -14, -4, 9, -13, -8, 2, -11, 12, -7, 14, 0, -5, -2, 7, 5, 5, -3, 13, -6, -8, -10, -10, -9, 0, 6, -12, 11, 2, 11, 1, 13, 4, 12, -1, 6, -11, -14, 2, 9, -6, 1, -6, -4, 14, -13, 8, 4, -1, 6, 6, -2, 11, 11, 4, -4, -5, -1, -8, 12, -13, 1, 10, 7, -10, -14, -10, -5, -13, 0, 11};
        //    int arr[] = {-1,0,1,2,-1,-4};
        System.out.println(test(arr));
        long ed = System.currentTimeMillis();
        System.out.println(ed - srt + "ms");

    }

    public static List<List<Integer>> test(int arr[]) {
        //int arr[] = {-1, 0, 1, 2, -1, 4};
        int m = 0;
        int brr[][] = new int[200][200];
        List<Integer> err = null;

        List<List<Integer>> drr = new ArrayList<>();
        Arrays.sort(arr);
        aa:
        for (int i = 0; i < arr.length; i++) {
            for (int j = i + 1, k = arr.length - 1; j < arr.length && j < k;j++) {
                if(arr[j]<arr[i]){
                    continue ;
                }
                while (j + 1 < k && arr[j] == arr[j + 1]) {
                    j++;
                }
                while (k - 1 > j && arr[k] == arr[k - 1]) {
                    k--;
                }
                if(arr[k]<arr[j]){
                    k--;
                }
                for (int n = 0; n < m; n++) {
                    if (arr[i] == brr[n][0] && arr[j] == brr[n][1] && arr[k] == brr[n][2]) {
                        continue aa;
                    }
                    if (arr[i] == brr[n][0] && arr[j] == brr[n][2] && arr[k] == brr[n][1]) {
                        continue aa;
                    }
                    if (arr[i] == brr[n][1] && arr[j] == brr[n][2] && arr[k] == brr[n][0]) {
                        continue aa;
                    }
                    if (arr[i] == brr[n][1] && arr[j] == brr[n][0] && arr[k] == brr[n][2]) {
                        continue aa;
                    }
                    if (arr[i] == brr[n][2] && arr[j] == brr[n][1] && arr[k] == brr[n][0]) {
                        continue aa;
                    }
                    if (arr[i] == brr[n][2] && arr[j] == brr[n][0] && arr[k] == brr[n][1]) {
                        continue aa;
                    }


                }
                if (arr[i] + arr[j] + arr[k] == 0) {
                    ++m;
                    //brr = new int[++m][3];
                    brr[m - 1][0] = arr[i];
                    brr[m - 1][1] = arr[j];
                    brr[m - 1][2] = arr[k];
                }else{

                }
            }
        }
        int crr[][] = new int[m][3];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < 3; j++) {
                crr[i][j] = brr[i][j];
            }
        }

        for (int i = 0; i < crr.length; i++) {
            err = new ArrayList<Integer>();
            for (int j = 0; j < 3; j++) {
                err.add(crr[i][j]);
            }

            drr.add(err);
        }

        return drr;

    }


}


